package com.shushan.accessibility.funtouch;

import android.text.TextUtils;
import android.util.Log;
import android.view.accessibility.AccessibilityNodeInfo;

import com.shushan.accessibility.AccessibilityOperator;
import com.shushan.util.ToolUtils;

import java.util.List;

/**
 * @ClassName: FuntouchOperator
 * @Desciption: vivo辅助功能操作类
 * @author: yichaohua
 * @date: 2018-07-04
 */
public class FuntouchOperator {

    private static final String TAG = "FuntouchOperator";

    private static FuntouchOperator mInstance = new FuntouchOperator();

    public static FuntouchOperator getInstance() {
        return mInstance;
    }

    public boolean closeSavePower() {
        return AccessibilityOperator.getInstance().clickListItem("书山宝",1);
    }

    public boolean enableAdmin() {
        return AccessibilityOperator.getInstance().clickByText("android.widget.Button","激活");
    }

    public boolean openUsageSetting() {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        boolean result = AccessibilityOperator.getInstance().clickListItem("书山宝",1);
        Log.i(TAG,"result=" + result);
        if(!result){
            return false;
        }else {
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            return AccessibilityOperator.getInstance().clickById("android:id/checkbox");
        }

    }
}
